package stream;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class SortPoint {
    public static void main(String[] args) {
        List<Point> list = new ArrayList<>();
        list.add(new Point(1,2));
        list.add(new Point(3,3));
        list.add(new Point(56,243));
        list.add(new Point(98,54));
        list.add(new Point(70,66));
        System.out.println(list);

        Collections.sort(list,(o1,o2)->o1.getX()-o2.getX());
        System.out.println(list);

        Collections.sort(list, new Comparator<Point>() {
            @Override
            public int compare(Point o1, Point o2) {
                return o1.getY()-o2.getY();
            }
        });
        System.out.println(list);
    }
}
